package cn.b504.qpcr.controller;

import azure2java.qpcradapter.adapter.entity.StatusBean;
import cn.b504.qpcr.entity.AjaxResult;
import cn.b504.qpcr.entity.Data;
import cn.b504.qpcr.entity.OperationInfo;
import cn.b504.qpcr.entity.data.QuantificationData;
import cn.b504.qpcr.interfaces.Device;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/deviceAction")
public class DeviceController {
  private final Device device;

  public DeviceController(Device device) {
    this.device = device;
  }

  @RequestMapping("/search")
  public AjaxResult search() {
    return device.search();
  }

  @RequestMapping("/disconnect")
  public void disconnect(@RequestBody String connectPort) {
    device.disconnect(connectPort);
  }

  @RequestMapping("/connect")
  public AjaxResult connect(@RequestBody String connectPort) {
    return device.connect(connectPort);
  }

  @RequestMapping("/start")
  public AjaxResult start(@RequestBody Data data) {
    return device.start(data);
  }

  @RequestMapping("/stop")
  public AjaxResult stop(@RequestBody OperationInfo info) {
    return device.stop(info);
  }

  @RequestMapping("/pause")
  public AjaxResult pause(@RequestBody OperationInfo info) {
    return device.pause(info);
  }

  @RequestMapping("/restart")
  public AjaxResult restart(@RequestBody OperationInfo info) {
    return device.restart(info);
  }

  @RequestMapping("/controlTray")
  public AjaxResult controlTray(@RequestBody Data data) { return device.controlTray(data); }

  @RequestMapping("/refreshData")
  public short refreshData(@RequestBody String ip) {
    return device.refreshData(ip);
  }

  @RequestMapping("/getPCRData")
  public QuantificationData getPCRData(@RequestBody String ip) {
    return device.getPCRData(ip);
  }

  @RequestMapping("/getMeltData")
  public List<List<Float>> getMeltData(@RequestBody String ip) {
    return device.getMeltData(ip);
  }

  @RequestMapping("/getStatus")
  public StatusBean getStatus(@RequestBody String ip) {
    return device.getStatus(ip);
  }
}
